var uid = getParameter("uid");
var day = getParameter("Day");
var date = getParameter("date");
var now = new Date();
var arg;
$(function() {
	rt(now);

});

function rt(data) {
	var date = now.format("yyyy-MM-dd");
	var html="";
	html = '<table class="bordered"><thead> '+ 
    "<tr>" +
    "<th rowspan='2'>日期</th>" +
    "<th colspan='2'>早餐</th>" +
    "<th colspan='2'>午餐</th>" +
    "<th colspan='2'>晚餐</th>" +
    "<th>睡前</th>" +
    "</tr><tr>" +
    "<th><font color='white'>前</font></th>" +
    "<th><font color='white'>后</font></th>" +
    "<th><font color='white'>前</font></th>" +
    "<th><font color='white'>后</font></th>" +
    "<th><font color='white'>前</font></th>" +
    "<th><font color='white'>后</font></th>" +
    "<th></th>"+ 
     '</tr></thead>';
	if(day == 1){
		arg = 1;
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+getLastDay(now,int).format("MM-dd")+
		     '</td>'+canqian(isnull(6.8))
		     +canhou(isnull())+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull())+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
	}else if(day == 7){
		arg = 7;
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,6-int).format("MM-dd")+
		     '</td>'+canqian(isnull())
		     +canhou(isnull('8.0'))+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull())+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,4-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull(7.9))
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,3-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(8.3))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(7.8))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,2-int).format("MM-dd")+
			'</td>'+canqian(isnull('7.0'))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(9.4))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,1-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull("8.0"))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+getLastDay(now,int).format("MM-dd")+
		     '</td>'+canqian(isnull(6.8))
		     +canhou(isnull())+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull())+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
	}else if(day == 30){
		arg = 30;
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,29-int).format("MM-dd")+
			'</td>'+canqian(isnull(6.8))
			+canhou(isnull(11.3))+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull(6.1))+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,28-int).format("MM-dd")+
			'</td>'+canqian(isnull(7.8))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull('10.0'))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,27-int).format("MM-dd")+
		     '</td>'+canqian(isnull())
		     +canhou(isnull(10.2))+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull())+canhou(isnull(9.8))
		     +canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,26-int).format("MM-dd")+
			'</td>'+canqian(isnull(6.5))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull(6.2))+canhou(isnull())
			+canhou(isnull(10.2))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,25-int).format("MM-dd")+
			'</td>'+canqian(isnull(6.2))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull(9.7))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,24-int).format("MM-dd")+
			'</td>'+canqian(isnull('6.0'))
			+canhou(isnull('11.0'))+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,23-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(12.1))
			+canqian(isnull())+canhou(isnull(9.1))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,22-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull(9.3))+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(8.7))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,20-int).format("MM-dd")+
		     '</td>'+canqian(isnull(7.1))
		     +canhou(isnull())+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull('7.0'))+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,19-int).format("MM-dd")+
			'</td>'+canqian(isnull(5.9))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(8.9))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,18-int).format("MM-dd")+
			'</td>'+canqian(isnull(6.8))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull(9.9))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,17-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(9.8))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(8.9))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,16-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull(8.3))
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,15-int).format("MM-dd")+
			'</td>'+canqian(isnull(7.1))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull(6.8))+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,14-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(8.9))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(7.8))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,13-int).format("MM-dd")+
		     '</td>'+canqian(isnull())
		     +canhou(isnull())+canqian(isnull())
		     +canhou(isnull(9.3))
		     +canqian(isnull())+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,12-int).format("MM-dd")+
			'</td>'+canqian(isnull(7.3))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(7.7))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,11-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(9.1))
			+canqian(isnull())+canhou(isnull(9.8))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,10-int).format("MM-dd")+
			'</td>'+canqian(isnull(6.8))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(8.2))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,9-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(8.7))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,7-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(11.1))
			+canqian(isnull('7.0'))+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,6-int).format("MM-dd")+
		     '</td>'+canqian(isnull())
		     +canhou(isnull('8.0'))+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull())+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,4-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull(7.9))
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,3-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(8.3))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull(7.8))+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,2-int).format("MM-dd")+
			'</td>'+canqian(isnull('7.0'))
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull(9.4))
			+canqian(isnull())+canhou(isnull())
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+ getLastDay(now,1-int).format("MM-dd")+
			'</td>'+canqian(isnull())
			+canhou(isnull())+canqian(isnull())
			+canhou(isnull())
			+canqian(isnull())+canhou(isnull('8.0'))
			+canhou(isnull())+'</tr>';
		}
		for (var int = 0; int < 1; int++) {
			html+= '<tr><td>'+getLastDay(now,int).format("MM-dd")+
		     '</td>'+canqian(isnull(6.8))
		     +canhou(isnull())+canqian(isnull())
		     +canhou(isnull())
		     +canqian(isnull())+canhou(isnull())
		     +canhou(isnull())+'</tr>';
		}
	}
	
	$("#container").html(html);
	//设置表格颜色
	$("tr:odd").each(function(index) {
		$(this).css("background-color","#e0ecfb");
	});
	$("tr:first").css("color","#ffffff");
}
//判断是否合理
function canqian(r){
	if(r >= 4.3001 && r <= 7.0001){
		return '<td>'+r+'</td>';
	}else{
		return '<td style="color:red;">'+r+'</td>';
	}
}
function canhou(r){
	if(r>4.3001 && r < 10.0001){
		return '<td>'+r+'</td>';
	}else{
		return '<td style="color:red;">'+r+'</td>';
	}
}
function isnull(value) {
	if(value == null || value == "" || value == undefined){
		return "";
	}else{
		return value;
	}
}
/*$(function() {
	// swipe 的dome
	$("#container").swipe(
			{
				swipeLeft : function(event, direction, distance, duration,
						fingerCount) {

					now = getNextDay(now, arg);
					rt(now);
				},
				swipeRight : function(event, direction, distance, duration,
						fingerCount) {
					now = getLastDay(now, arg);
					rt(now);
				}
			});

});
*/